from rest_framework import serializers
from . import models


class CourseCategorySerializer(serializers.ModelSerializer):
    """课程分类序列化"""

    class Meta:
        model = models.CourseCategory
        fields = ['id', 'name']


class TeacherSerializer(serializers.ModelSerializer):
    """课程列表的讲师信息序列化"""

    class Meta:
        model = models.Teacher
        fields = ["id", "name", "role", "title", "signature", "brief", "image"]


class CourseSerializer(serializers.ModelSerializer):
    """课程列表信息序列化"""
    teacher = TeacherSerializer()

    class Meta:
        model = models.Course
        fields = ["id", "name", "course_img", "students", "lessons", "pub_lessons", "price", "teacher",
                  'free_lesson_list', 'discount_name', 'discount_price']
        # depth = 2


class CourseRetrieveSerializer(serializers.ModelSerializer):
    """课程详情序列化"""
    teacher = TeacherSerializer()

    class Meta:
        model = models.Course
        fields = ["id", "name", "course_img", 'course_video', "students", "lessons", "pub_lessons", "price", "teacher",
                  "brief", "level_name", 'discount_name', 'discount_price', 'has_time']


# class CourseLessonModelSerializer(serializers.ModelSerializer):
#     """课程课时"""
#
#     class Meta:
#         model = models.CourseLesson
#         fields = []


class CourseChapterModelSerializer(serializers.ModelSerializer):
    """课程章节"""

    class Meta:
        model = models.CourseChapter
        fields = ["chapter", "name", "summary", "lesson_data"]
